import { IonicPage, NavController, NavParams, Slides } from 'ionic-angular';
import { nailerService } from '../../../providers/nailerService';

import { Component, Injector, ViewChild } from '@angular/core';
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
import { BasePage } from './../../../pages/basePage';
import { StorageService } from './../../../providers/StorageService';
// import { UserService } from './../../../providers/UserService';
import { PIC_URL } from "./../../../providers/Config";
declare var Swiper;

/**
 * Generated class for the MyNailsPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-my-nails',
  templateUrl: 'my-nails.html',
})
export class MyNailsPage extends BasePage {
  text: string;

  picrooturl = "";//图片服务地址
  userinfo = {}//获取内存中的数据

  /**账单详情参数 */
  param={
    user_id:null,
  }
  billList=[];  //美甲师的账单
  // billList2=[]; //店铺的收益

  constructor(injector: Injector, public nailerService: nailerService, public stc: StorageService) {
    super(injector);
  }



ionViewDidLoad(){
  this.userinfo = this.stc.read('userinfo');
  this.picrooturl = PIC_URL
  console.log(this.userinfo)
  this.param.user_id=this.userinfo["user_id"]
  this. getBill()
}

  /**关闭美甲师订单 */
  dismissCLI() {
    this.viewCtrl.dismiss();
  }


  /*获取数据*/
  async getBill(){
    //获取美甲师的账单
    this.billList =[];
    console.log(this.param)
    let result = await this.nailerService.artistIncomeAPI(this.param);  
    console.log(result);

    if (result.code == 0) {
      this.billList = result.data.income_list;
      console.log(this.billList)
      /**日起截取 */
      for(let i=0;i<this.billList.length;i++){
        this.billList[i].nail_expire=this.billList[i].nail_expire.split(" ").slice(0,1).toString();
        this.billList[i].order_time=this.billList[i].order_time.split(" ").slice(0,1).toString();
      }
      console.log(this.billList)
    } else {
      this.showAlert(result.msg);
    }  
  }
}
